<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改任务')" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-taskMission-edit" th:object="${taskMission}">
        <input id="missionId" name="missionId" type="hidden" th:field="*{missionId}"/>
        <div class="form-group">
            <label class="col-sm-2 control-label">任务标题：</label>
            <div class="col-sm-9">
                <input class="form-control" type="text" name="missionTitle" id="missionTitle" th:field="${taskMission.missionTitle}" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label ">任务内容：</label>
            <div class="col-sm-9">
                <input class="form-control" type="text" name="missionText" id="missionText" th:field="${taskMission.missionText}" required>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-2 control-label ">完成时间：</label>
            <div class="col-sm-4">
            <input class="form-control" type="datetime-local" name="createTime" id="createTime"  th:value="${#dates.format(taskMission.createTime,'yyyy-MM-dd')}+'T'+${#dates.format(taskMission.createTime,'HH:mm:ss')}" required>
            </div>
            <div class="col-sm-4">
                <input class="form-control" type="datetime-local" name="endTime" id="endTime" th:value="${#dates.format(taskMission.endTime,'yyyy-MM-dd')}+'T'+${#dates.format(taskMission.endTime,'HH:mm:ss')}" required step="1">
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-2 control-label">紧急程度：</label>
            <div class="col-sm-9">

                    <label class="radio-box">
                            <input type="radio"
                                   th:checked="${taskMission.urgencyLevel eq '0'}"
                                    id="optionsRadios1" name="urgencyLevel" value="0" style="position: absolute; opacity: 0;">
                       普通
                    </label>

                        <label class="radio-box">
                            <input type="radio"
                                   th:checked="${taskMission.urgencyLevel eq '1'}"
                                   id="option2" name="urgencyLevel"  value="1" style="position: absolute; opacity: 0;">
                            紧急
                        </label>

                        <label class="radio-box">

                            <input type="radio"
                                   th:checked="${taskMission.urgencyLevel eq '2'}"
                                   id="option3" name="urgencyLevel"  value="2" style="position: absolute; opacity: 0;">
                            非常紧急
                        </label>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">部门：</label>
            <div class="col-sm-4">
                <select name="deptId"  class="form-control" id="deptId">
                    <option>请选择部门</option>
                    <option th:each="dept : ${personDepts}" th:value="${dept.deptId}" th:text="${dept.deptName}" th:selected="${personInfo.personDept.deptId eq dept.deptId}"></option>
                </select>
            </div>

            <label class="col-sm-2 control-label">执行人员：</label>
            <div class="col-sm-4">
                <select name="infoId"  class="form-control" id="infoId">
                    <option>请选择执行人</option>
                    <option value="-1">无</option>
                    <option th:each="person : ${list}" th:value="${person.infoId}" th:text="${person.infoName}" th:selected="${personInfo.infoId eq person.infoId}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">备注：</label>
            <div class="col-sm-9">
                <img th:src="@{${taskMission.url}}"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">备注：</label>
            <div class="col-sm-9">
                <textarea id="remark" name="remark" class="form-control">[[*{remark}]]</textarea>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer" />
<script type="text/javascript">

    $(function () {
        $("#deptId").change(function () {
            var deptId = $("#deptId").val();
            console.log(deptId);
            $.post(
                '/task/mission/selectPersomInfo',
                {
                    deptId:deptId
                },
                function(data){
                    console.log(data);
                    if(data != null){
                        $("#infoId").empty();
                        for(var i = 0 ; i < data.length ; i++){
                            $("#infoId").append("<option value='" + data[i].infoId + "'>" + data[i].infoName + "</option>");
                        }
                    }
                },"json"
            )
        });
    });

    var prefix = ctx + "task/mission";

    $("#form-taskMission-edit").validate({
        onkeyup: false,
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/edit", $('#form-taskMission-edit').serialize());
        }
    }
</script>
</body>
</html>
